﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Yunzuan.Foundation.Entities
{
    /// <summary>
    /// 用于方法返回值
    /// </summary>
    public class HashResult : Hashtable
    {
        public bool IsNull { get; set; }

        public int? GetInt(string columnName)
        {
            if (this[columnName] == null)
            {
                return null;
            }
            return Convert.ToInt32(this[columnName]);
        }

        public int GetInt(string columnName, int defaultValue)
        {
            if (this[columnName] == null)
            {
                return defaultValue;
            }
            return Convert.ToInt32(this[columnName]);
        }

        public string GetString(string columnName)
        {
            return this[columnName].ToString();
        }

        public decimal? GetDecimal(string columnName)
        {
            if (this[columnName] == null)
            {
                return null;
            }
            return Convert.ToDecimal(this[columnName]);
        }

        public decimal GetDecimal(string columnName, decimal defaultValue)
        {
            if (this[columnName] == null)
            {
                return defaultValue;
            }
            return Convert.ToDecimal(this[columnName]);
        }

        public DateTime? GetDataTime(string columnName)
        {
            if (this[columnName] == null)
            {
                return null;
            }
            return Convert.ToDateTime(this[columnName]);
        }

        public DateTime GetDataTime(string columnName, DateTime defaultValue)
        {
            if (this[columnName] == null)
            {
                return defaultValue;
            }
            return Convert.ToDateTime(this[columnName]);
        }

        public bool GetBool(string columnName)
        {
            if (this[columnName] == null)
            {
                return false;
            }
            return Convert.ToBoolean(this[columnName]);
        }
    }
}
